$(function() {
	// 热门搜索
	$('#hotSearch').on('click', 'a', function() {
		var text = $(this).text();
		$('.search-input').val(text);
	});
	//检索
	$('#search_skw_sub').on('click', function() {
		var type = $('.search-select').attr('value') || 1;
		var val = $('#skw').val() || '';
		if (val != '') {
			var url = '';
			if (type == 2) {
				url =
					'http://www.sczwfw.gov.cn/jsearchfront/search.do?websiteid=511500000000000&pg=10&tpl=1&q=' +
					val;
			};
			window.open(encodeURI(url))
		}
	});
	// 自定义select
	$('.search-select').on('click', '.hd', function(e) {
		e.stopPropagation(); //e.preventDefault();
		var that = e.delegateTarget;
		var bd = $(that).children('.bd');
		if (bd.css('display') == 'none') {
			$(this).addClass('on');
			bd.slideDown();
		} else {
			$(this).removeClass('on');
			bd.slideUp();
		}
	});
	$('.search-select').on('click', '.bd li', function(e) {
		var text = $(this).text();
		var val = this.value || text;
		$('.search-select .hd').html(text);
		$('.search-select').attr('value', val);
	});
	$(document).on('click', function(e) {
		$('.search-select .hd').removeClass('on');
		$('.search-select .bd').slideUp();
	});
	//友情链接跳转
	$('.links').on('change','select',function(e){
		if(this.selectedIndex != 0){
			var url = this.value;
			if(url != ''){
				window.open(encodeURI(url))
			};
			this.options[0].selected = true
		}
	})
});